home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / cfengine-1.5.3 / src / net.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-10  |  2.4 KB  |  88 lines

  1. /* cfengine for GNU
  2.  
  3.         Copyright (C) 1995
  4.         Free Software Foundation, Inc.
  5.  
  6.    This file is part of GNU cfengine - written and maintained 
  7.    by Mark Burgess, Dept of Computing and Engineering, Oslo College,
  8.    Dept. of Theoretical physics, University of Oslo
  9.  
  10.    This program is free software; you can redistribute it and/or modify it
  11.    under the terms of the GNU General Public License as published by the
  12.    Free Software Foundation; either version 2, or (at your option) any
  13.    later version.
  14.  
  15.    This program is distributed in the hope that it will be useful,
  16.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.    GNU General Public License for more details.
  19.  
  20.   You should have received a copy of the GNU General Public License
  21.   along with this program; if not, write to the Free Software
  22.   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  23.  
  24. */
  25.  
  26.  
  27. /*********************************************************************/
  28. /*                                                                   */
  29. /*  TOOLKITS: network library                                        */
  30. /*                                                                   */
  31. /*********************************************************************/
  32.  
  33. #include "cf.defs.h"
  34. #include "cf.extern.h"
  35.  
  36. /*************************************************************************/
  37.  
  38.  
  39. TimeOut()
  40.  
  41. {
  42. alarm(0);
  43. Verbose("%s: Time out\n",VPREFIX);
  44. }
  45.  
  46. /*************************************************************************/
  47.  
  48. RecvSocketStream(sd,buffer,toget,nothing)
  49.  
  50. int sd,toget,nothing;
  51. char buffer[bufsize];
  52.  
  53. { int already, got;
  54.   static int fraction;
  55.   char *sp; 
  56.  
  57. Debug("RecvSocketStream(%d)\n",toget);
  58.  
  59. for (already = 0; already != toget; already += got)
  60.    {
  61.    got = recv(sd,buffer+already,toget-already,0);
  62.  
  63.    if (got == -1)
  64.       {
  65.       CfLog(cferror,"Couldn't recv","recv");
  66.       return -1;
  67.       }
  68.  
  69.    if (got == 0)   /* doesn't happen unless sock is closed */
  70.       {
  71.       Debug("Transmission empty...\n");
  72.       fraction = 0;
  73.       return already;
  74.       }
  75.  
  76.    Debug("    (Concatenated %d from stream)\n",got);
  77.  
  78.    if (strncmp(buffer,"AUTH",4) == 0 && (already == bufsize))
  79.       {
  80.       fraction = 0;
  81.       return already;
  82.       }
  83.    }
  84.  
  85. return toget;
  86. }
  87.  
  88.